using I2.Loc;
using UnityEngine;

public class MarathonWindow : MonoBehaviour
{
	public static MarathonWindow instance;

	public GameObject windowAward;

	public GameObject windowInfo;

	public Texture txCoins;

	public Texture txCash;

	public ScrollDaysMarathon scrollAllDays;

	public ScrollDaysMarathon scrollSuperDays;

	public ButAwardMarathon curAward;

	public UILabel lbNameAward;

	public UILabel lbInfoAward;

	public UITexture txAward;

	private void Awake()
	{
		instance = this;
	}

	private void OnDestroy()
	{
		instance = null;
	}

	public void ShowWindow()
	{
		scrollAllDays.UpdateList();
		scrollSuperDays.UpdateList(true);
		if ((bool)curAward)
		{
			curAward.SetInfo(MarathonController.instance.curDayAward, true);
		}
		if ((bool)windowAward)
		{
			windowAward.SetActive(true);
		}
		if ((bool)windowInfo)
		{
			windowInfo.SetActive(false);
		}
		scrollAllDays.CenterOnCurrentDay();
	}

	public void ShowInfoAward(DayMarathon curAward)
	{
		ButAwardMarathon butAward = scrollAllDays.GetButAward(curAward.curNumDayAward);
		if ((bool)butAward)
		{
			if ((bool)lbNameAward)
			{
				lbNameAward.text = butAward.lbNameCount.text;
			}
			if ((bool)txAward)
			{
				txAward.mainTexture = butAward.txAward.mainTexture;
			}
			if ((bool)lbInfoAward)
			{
				lbInfoAward.text = instance.GetInfoFor(curAward.idProduct);
			}
			lbInfoAward.text = lbInfoAward.text.Replace("10", curAward.count.ToString());
		}
		if ((bool)windowInfo)
		{
			windowInfo.SetActive(true);
		}
	}

	public void CloseInfo()
	{
		if ((bool)windowInfo)
		{
			windowInfo.SetActive(false);
		}
	}

	public void CloseWindowAndGiveAward()
	{
		MarathonController.instance.GiveAward(MarathonController.instance.curDayAward);
		windowAward.SetActive(false);
	}

	public Texture GetTextureFor(string id)
	{
		if (id.ToLower().Equals("coins"))
		{
			return txCoins;
		}
		if (id.ToLower().Equals("cash"))
		{
			return txCash;
		}
		return MarketController.Instance.GetProductTexture(id);
	}

	public string GetNameFor(string id)
	{
		if (id.ToLower().Equals("coins"))
		{
			return ScriptLocalization.Get("Marathon/Coins");
		}
		if (id.ToLower().Equals("cash"))
		{
			return ScriptLocalization.Get("Marathon/Cash");
		}
		Product product = MarketController.Instance.GetProduct(id);
		if (product != null)
		{
			return ScriptLocalization.Get("Market/" + product.id + "_title");
		}
		if (BCWDebug.isDebugBuild)
		{
			BCWDebug.Log("none texture");
		}
		return null;
	}

	public string GetInfoFor(string id)
	{
		if (id.ToLower().Equals("coins"))
		{
			return ScriptLocalization.Get("Marathon/Coins");
		}
		if (id.ToLower().Equals("cash"))
		{
			return ScriptLocalization.Get("Marathon/Cash");
		}
		Product product = MarketController.Instance.GetProduct(id);
		if (product != null)
		{
			return ScriptLocalization.Get("Market/" + product.id + "_info");
		}
		if (BCWDebug.isDebugBuild)
		{
			BCWDebug.Log("none texture");
		}
		return null;
	}
}
